package rsj.api.report;

import com.rlyy.aibase.utils.base.Box;
import common.util.BoxUtil;
import common.util.validator.ParameterConversionCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.report.entity.CustomerReport;
import rsj.api.report.entity.CustomerReportDetail;
import rsj.api.report.entity.ReportParam;
import rsj.service.report.IReportService;

import javax.validation.groups.Default;
import java.util.List;

/**
 * 客户报表
 *
 * @author yuanqinglong
 * @since 2021/7/21 17:58
 */
@RestController
public class CustomerReportController {


    /**
     * 客户报告服务
     */
    @Autowired
    private IReportService<CustomerReport, CustomerReportDetail, ReportParam> customerReportServiceImpl;


    /**
     * 客户报表列表
     *
     * @param param 参数
     * @return {@link Box}
     */
    @RequestMapping(value = "rsj_report_customer_list")
    public Box reportList(Box param) {
        ReportParam reportParam = ParameterConversionCheck.parameterConversionCheckFastFail(param, ReportParam.class,
                ReportParam.Table.class, Default.class);
        List<CustomerReport> customerReports = customerReportServiceImpl.reportList(reportParam);
        int count = customerReportServiceImpl.reportCount(reportParam);
        return BoxUtil.successBoxToTableData(param, customerReports, count);
    }


    /**
     * 客户详细的列表
     *
     * @param param 参数
     * @return {@link Box}
     */
    @RequestMapping(value = "rsj_report_customer_detail_list")
    public Box detailList(Box param) {
        ReportParam reportParam = ParameterConversionCheck.parameterConversionCheckFastFail(param, ReportParam.class,
                ReportParam.Table.class, ReportParam.CustId.class, Default.class);
        List<CustomerReportDetail> customerReportDetails = customerReportServiceImpl.detailList(reportParam);
        int count = customerReportServiceImpl.detailCount(reportParam);
        return BoxUtil.successBoxToTableData(param, customerReportDetails, count);
    }



}
